<!doctype html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.0" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Android," />





  <link rel="alternate" href="/atom.xml" title="结网之路" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.0" />






<meta name="description" content="本章介绍了常用的 XML drawable，包括 shape，state list 和 layer list。还介绍了 9-patch 图片和 mipmap 目录等知识。
GitHub 地址：完成第21章

1. XML drawable在 Android 世界里，凡是要在屏幕上绘制的东西都可以叫作 drawable，比如抽象图形、 Drawable 类的子类、位图图像等。我们之前用来封装图片的">
<meta property="og:type" content="article">
<meta property="og:title" content="Android编程权威指南（第二版）学习笔记（二十一）—— 第21章 XML drawable">
<meta property="og:url" content="https://kniost.github.io/2017-02-04-cj0ag5y6o001hifs64uqyxo8y/index.html">
<meta property="og:site_name" content="结网之路">
<meta property="og:description" content="本章介绍了常用的 XML drawable，包括 shape，state list 和 layer list。还介绍了 9-patch 图片和 mipmap 目录等知识。
GitHub 地址：完成第21章

1. XML drawable在 Android 世界里，凡是要在屏幕上绘制的东西都可以叫作 drawable，比如抽象图形、 Drawable 类的子类、位图图像等。我们之前用来封装图片的">
<meta property="og:image" content="https://kniost.github.io/2017-02-04-cj0ag5y6o001hifs64uqyxo8y/9-patch.png">
<meta property="og:image" content="https://kniost.github.io/2017-02-04-cj0ag5y6o001hifs64uqyxo8y/9-patch效果图.png">
<meta property="og:updated_time" content="2017-03-14T07:08:20.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Android编程权威指南（第二版）学习笔记（二十一）—— 第21章 XML drawable">
<meta name="twitter:description" content="本章介绍了常用的 XML drawable，包括 shape，state list 和 layer list。还介绍了 9-patch 图片和 mipmap 目录等知识。
GitHub 地址：完成第21章

1. XML drawable在 Android 世界里，凡是要在屏幕上绘制的东西都可以叫作 drawable，比如抽象图形、 Drawable 类的子类、位图图像等。我们之前用来封装图片的">
<meta name="twitter:image" content="https://kniost.github.io/2017-02-04-cj0ag5y6o001hifs64uqyxo8y/9-patch.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    sidebar: {"position":"right","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://kniost.github.io/2017-02-04-cj0ag5y6o001hifs64uqyxo8y/"/>





  <title> Android编程权威指南（第二版）学习笔记（二十一）—— 第21章 XML drawable | 结网之路 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  














  
  
    
  

  <div class="container one-collumn sidebar-position-right page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">结网之路</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">临渊羡鱼，不如退而结网</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://kniost.github.io/2017-02-04-cj0ag5y6o001hifs64uqyxo8y/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="kniost">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="结网之路">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                Android编程权威指南（第二版）学习笔记（二十一）—— 第21章 XML drawable
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-02-04T16:48:10+08:00">
                2017-02-04
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Android编程权威指南学习笔记/" itemprop="url" rel="index">
                    <span itemprop="name">Android编程权威指南学习笔记</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2017-02-04-cj0ag5y6o001hifs64uqyxo8y/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count" data-disqus-identifier="2017-02-04-cj0ag5y6o001hifs64uqyxo8y/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <blockquote>
<p>本章介绍了常用的 XML drawable，包括 shape，state list 和 layer list。还介绍了 9-patch 图片和 mipmap 目录等知识。</p>
<p>GitHub 地址：<br><a href="https://github.com/kniost/Android-Programming-Big-Nerd-Ranch-Guide-2nd/commit/b037c855ab0f8be47795982ea1b735b4573819d7" target="_blank" rel="external">完成第21章</a></p>
</blockquote>
<h1 id="1-XML-drawable"><a href="#1-XML-drawable" class="headerlink" title="1. XML drawable"></a>1. XML drawable</h1><p>在 Android 世界里，凡是要在屏幕上绘制的东西都可以叫作 drawable，比如抽象图形、 Drawable 类的子类、位图图像等。我们之前用来封装图片的 BitmapDrawable 就是一种 drawable。 本章我们使用的 drawable 都定义在 XML 文件中，可以归为一类，统称为 XML drawable。</p>
<h2 id="1-1-为什么要使用-XML-drawable"><a href="#1-1-为什么要使用-XML-drawable" class="headerlink" title="1.1 为什么要使用 XML drawable"></a>1.1 为什么要使用 XML drawable</h2><p>XML drawable 用起来方便灵活，不仅用法多样，还易于更新维护。搭配使用 shape drawable<br>和 layer list drawable 可以做出复杂的背景图，连图像编辑器都省了。更改应用的配色更是简单，直接修改 XML drawable 中的颜色就行了。<br>另外，XML drawable 独立于屏幕像素密度，它们直接定义在 drawable 目录中，不需要加屏幕密度资源修饰符。如果是普通图像，就需要准备多个版本，以适配不同屏幕像素密度的设备;而 XML drawable 只要定义一次，就能在任何设备的屏幕上表现出色。</p>
<h2 id="1-2-shape-drawable"><a href="#1-2-shape-drawable" class="headerlink" title="1.2 shape drawable"></a>1.2 shape drawable</h2><p>一个常见的圆形 shape drawable 如下：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">&lt;?xml version="1.0" encoding="utf-8"?&gt;</div><div class="line"><span class="tag">&lt;<span class="name">shape</span> <span class="attr">xmlns:android</span>=<span class="string">"http://schemas.android.com/apk/res/android"</span></span></div><div class="line">       <span class="attr">android:shape</span>=<span class="string">"oval"</span>&gt;</div><div class="line"></div><div class="line">	<span class="tag">&lt;<span class="name">solid</span></span></div><div class="line">		<span class="attr">android:color</span>=<span class="string">"@color/red"</span>/&gt;</div><div class="line"></div><div class="line">	<span class="tag">&lt;<span class="name">stroke</span></span></div><div class="line">   		<span class="attr">android:width</span>=<span class="string">"4dp"</span></div><div class="line">   		<span class="attr">android:color</span>=<span class="string">"@color/dark_red"</span>/&gt;</div><div class="line"><span class="tag">&lt;/<span class="name">shape</span>&gt;</span></div></pre></td></tr></table></figure>
<p>该 shape drawable 定义了一个带有暗红色圆环的填充红色的椭圆。</p>
<ul>
<li>shape 标签中 android:shape 属性定义了其形状为椭圆（当然，如果需要是正圆，只需要把控件的高宽设为相等即可），还可以是长方形，线条，梯形等图形;</li>
<li>solid 标签定义填充，其中 android:color 定义其填充颜色（默认透明）</li>
<li>stroke 标签定义边框，属性都类似</li>
<li>还有更多标签和属性，可以在这里找到：<a href="https://developer.android.com/guide/topics/resources/drawable-resource.html#Shape" target="_blank" rel="external">shape drawable</a></li>
</ul>
<h2 id="1-3-state-list-drawable"><a href="#1-3-state-list-drawable" class="headerlink" title="1.3 state list drawable"></a>1.3 state list drawable</h2><p>为了在控件的不同状态下切换不同的 drawable， 我们用到了 state list drawable，它会根据按钮的状态改变使用的 drawable，一个例子如下：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">selector</span> <span class="attr">xmlns:android</span>=<span class="string">"http://schemas.android.com/apk/res/android"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">item</span> <span class="attr">android:drawable</span>=<span class="string">"@drawable/button_beat_box_pressed"</span></span></div><div class="line">          <span class="attr">android:state_pressed</span>=<span class="string">"true"</span>/&gt;</div><div class="line">    <span class="tag">&lt;<span class="name">item</span> <span class="attr">android:drawable</span>=<span class="string">"@drawable/button_beat_box_normal"</span>/&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">selector</span>&gt;</span></div></pre></td></tr></table></figure>
<p>将一个 drawable 资源文件定义为 selector，便是让系统根据状态选择。状态有按下，禁用，聚焦以及激活等状态，可以根据不同的状态使用不同的 drawable。</p>
<p>还有更多标签和属性，可以在这里找到：<a href="https://developer.android.com/guide/topics/resources/drawable-resource.html#StateList" target="_blank" rel="external">state list drawable</a></p>
<h2 id="1-4-layer-list-drawable"><a href="#1-4-layer-list-drawable" class="headerlink" title="1.4 layer list drawable"></a>1.4 layer list drawable</h2><p>layer list 可以将多个 drawable 组成一个 drawable 并可以指定其摆放层次和位置，可以组成一些复杂的效果。</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">layer-list</span> <span class="attr">xmlns:android</span>=<span class="string">"http://schemas.android.com/apk/res/android"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">item</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">shape</span> <span class="attr">android:shape</span>=<span class="string">"oval"</span>&gt;</span></div><div class="line"></div><div class="line">            <span class="tag">&lt;<span class="name">solid</span></span></div><div class="line">                <span class="attr">android:color</span>=<span class="string">"@color/red"</span>/&gt;</div><div class="line"></div><div class="line">        <span class="tag">&lt;/<span class="name">shape</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">item</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">item</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">shape</span> <span class="attr">android:shape</span>=<span class="string">"rectangle"</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">stroke</span></span></div><div class="line">                <span class="attr">android:width</span>=<span class="string">"4dp"</span></div><div class="line">                <span class="attr">android:color</span>=<span class="string">"@color/dark_red"</span>/&gt;</div><div class="line">        <span class="tag">&lt;/<span class="name">shape</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">item</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">layer-list</span>&gt;</span></div></pre></td></tr></table></figure>
<p>这个 layer list 将一个矩形叠放在一个椭圆上。还有更多的属性可以查看 <a href="https://developer.android.com/guide/topics/resources/drawable-resource.html#LayerList" target="_blank" rel="external">layer list drawable</a></p>
<h1 id="2-9-patch-图像（九宫格图像）"><a href="#2-9-patch-图像（九宫格图像）" class="headerlink" title="2. 9-patch 图像（九宫格图像）"></a>2. 9-patch 图像（九宫格图像）</h1><p>有时候，按钮背景图必须用到普通图片。那么，如果按钮需要以不同尺寸显示，背景图该如何变化呢?如果按钮的宽度大于背景图的宽度，图片会被拉伸。拉伸的图片会有很好的效果吗? 朝一个方向拉伸背景图很可能会让图片失去原样，所以得想个办法控制图片拉伸方式。</p>
<p>9-patch 就是这样一种方式，它将图像分成3×3的网格，即由9 patch 组成的网格。网格角落部分不会被缩放，边缘部分的4个 patch 只按一个维度缩放，而中间部分则按两个维度缩放，如下图：</p>
<img src="/2017-02-04-cj0ag5y6o001hifs64uqyxo8y/9-patch.png" alt="9-patch 示意图" title="9-patch 示意图">
<p>9-patch 图像和普通 PNG 图像十分相似，只有两处不同:9-patch 图像文件名以.9.png 结尾，图像边缘具有1像素宽度的边框。这个边框用以指定9-patch 图像的中间位置。边框像素绘制为黑线， 以表明中间位置，边缘部分则用透明色表示。</p>
<p>在 Android Studio 中，右键单击想要转换为 9-patch 的图像文件选择创建 9-patch 文件，然后双击打开，画上黑边即可。旁边会显示不同方向拉伸后的效果。</p>
<img src="/2017-02-04-cj0ag5y6o001hifs64uqyxo8y/9-patch效果图.png" alt="9-patch 效果图" title="9-patch 效果图">
<h1 id="3-mipmap-目录"><a href="#3-mipmap-目录" class="headerlink" title="3. mipmap 目录"></a>3. mipmap 目录</h1><p>应用要用到图像，就一般会针对不同的设备尺寸准备不同尺寸的图片，再分别放入 drawable-mdpi 和 drawable-hdpi 这样的文件夹。然后，按名字引用它们。 剩下的就交给 Android 了，它会根据当前设备的屏幕密度调用相应的图片。<br>这样就会存在一个问题：发布出去的 APK 文件包含了项目 drawable 目录里的所有图片，哪怕是从来不会用到的图片，这会让应用体积无意义地增大。为减轻负担，有人想到针对设备定制 APK，比如 mdpi APK 一个，hdpi APK 一个，等等。有关 APK 分包的详细信息，可参阅<a href="https://developer.android.com/studio/build/configure-apk-splits.html" target="_blank" rel="external">Build Multiple APKs</a></p>
<p>相反，设置分包以后，有的时候会需要不同分辨率的图标，比如启动器不同，需要的图标清晰度不同，所以，要用到 mipmap 目录。APK 分包时，mipmap 资源会全部包含在 APK 文件中。</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Android/" rel="tag"># Android</a>
          
        </div>
      

      
        
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017-01-31-cj0ag5y6m001eifs6utetaefs/" rel="next" title="Android编程权威指南（第二版）学习笔记（二十）—— 第20章 样式与主题">
                <i class="fa fa-chevron-left"></i> Android编程权威指南（第二版）学习笔记（二十）—— 第20章 样式与主题
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017-02-07-cj0ag5y6q001kifs6872frh9c/" rel="prev" title="Android编程权威指南（第二版）学习笔记（二十二）—— 第22章 深入学习 intent 和任务">
                Android编程权威指南（第二版）学习笔记（二十二）—— 第22章 深入学习 intent 和任务 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>

          
          </div>
          


          
  <div class="comments" id="comments">
    
      <div id="disqus_thread"></div>
<script>

/**
*  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
*  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://kniost-comment-github.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
                                
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.jpg"
               alt="kniost" />
          <p class="site-author-name" itemprop="name">kniost</p>
           
              <p class="site-description motion-element" itemprop="description">kniost 的成长与疑惑</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/archives">
                <span class="site-state-item-count">31</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/categories/index.html">
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#1-XML-drawable"><span class="nav-text">1. XML drawable</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-1-为什么要使用-XML-drawable"><span class="nav-text">1.1 为什么要使用 XML drawable</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#1-2-shape-drawable"><span class="nav-text">1.2 shape drawable</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#1-3-state-list-drawable"><span class="nav-text">1.3 state list drawable</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#1-4-layer-list-drawable"><span class="nav-text">1.4 layer list drawable</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#2-9-patch-图像（九宫格图像）"><span class="nav-text">2. 9-patch 图像（九宫格图像）</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#3-mipmap-目录"><span class="nav-text">3. mipmap 目录</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">kniost</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    
    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  




  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.0"></script>



  



  

    <script type="text/javascript">
      var disqus_shortname = 'kniost-comment-github';
      var disqus_identifier = '2017-02-04-cj0ag5y6o001hifs64uqyxo8y/';

      var disqus_title = "Android编程权威指南（第二版）学习笔记（二十一）—— 第21章 XML drawable";


      function run_disqus_script(disqus_script) {
        var dsq = document.createElement('script');
        dsq.type = 'text/javascript';
        dsq.async = true;
        dsq.src = '//' + disqus_shortname + '.disqus.com/' + disqus_script;
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
      }

      run_disqus_script('count.js');

      
        var disqus_config = function () {
            this.page.url = disqus_url;
            this.page.identifier = disqus_identifier;
            this.page.title = disqus_title;
        };
        run_disqus_script('embed.js');
      

    </script>
  










  
  

  

  

  

  


  

</body>
</html>
